using System.Linq;
using Core;
using IglooCoder.Commons.WcfNhibernate;
using NHibernate;
using NHibernate.Linq;

namespace Infrastucture
{
    public class DeliveryOrderElseRepository : BaseNHibernateRepository<DeliveryOrderElse>
    {
        public DeliveryOrderElseRepository(ISessionStorage sessionStorage)
            : base(sessionStorage)
        {
        }


        public string GetMaxNumber()
        {
            string res = string.Empty;

            using (ITransaction tx = Session.BeginTransaction())
            {
                res = Session.Linq<DeliveryOrderElse>().Max(p => p.DONo);
                tx.Commit();
            }

            return res;
        }

        public void UpdateStatus(string doNo, int Status)
        {
            ISQLQuery command =
            Session.CreateSQLQuery("Update DeliveryOrderElse set Status=" + Status + " Where NoBtb='" + doNo + "'");
            int res = command.ExecuteUpdate();
        }
    }
}